package connector;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

public class Connection1 {
    public static void main(String[] args) {
        Driver driver = null;

        try {
            // step1 加载 MySQL 驱动程序
            driver = new com.mysql.jdbc.Driver();

            // step2 数据库的连接字符串
            // String url = "jdbc:mysql://localhost:3306/mysql";
            String url = "jdbc:mysql://localhost:3306/mysql?useSSL=false";

            // step3 访问数据库的账号信息
            Properties info = new Properties();
            info.setProperty("user", "root");
            info.setProperty("password", "it");

            // step4 连接到数据库
            Connection connection = driver.connect(url, info);
            System.out.println(connection);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
